package create.builder.demo.meal;

import create.builder.demo.food.Burger;
import create.builder.demo.food.Drink;

import java.util.Locale;

/**
 * @AUTHOR LYF
 * @DATE 2022/3/17
 * @VERSION 1.0
 * @DESC
 */
public class MealBuilder {
  // 改造
  //  static MealBuilder mealBuilder=new MealBuilder();// 放在静态--方法区--否则stackoverflow

    Meal meal;

//    public Meal build(){return this.meal;}
//     public MealBuilder(){
////        mealBuilder = new MealBuilder();
//        meal=new Meal();
//    }
//
//    public MealBuilder drink(Drink drink){
//        //MealBuilder mealBuilder = new MealBuilder();
//        this.mealBuilder.meal.addItem(drink);
//        return mealBuilder;
//    }
//
    // ----改造-----

    public Meal build(){return this.meal;}
    public MealBuilder(){
//        mealBuilder = new MealBuilder();
        meal=new Meal();
    }

    public MealBuilder drink(Drink drink){
        //MealBuilder mealBuilder = new MealBuilder();
        this.meal.addItem(drink);
        return this;
    }

    //
    public MealBuilder burger(Burger burger){
        //MealBuilder mealBuilder = new MealBuilder();
        this.meal.addItem(burger);
        return this;
    }

    // 定制
//    Meal preNoDrinkMeal1(){
//        Meal meal = new Meal();
//        return meal;
//    }
}
